package com.linln.wxapi;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.linln.common.utils.ResultVoUtil;
import com.linln.common.vo.ResultVo;
import com.linln.modules.member.domain.MemberShare;
import com.linln.modules.member.service.MemberShareService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(value="分享接口")
@RestController
@RequestMapping("/wx/membershare/{area}")
public class WxApiMemberShareController {

	   @Autowired
	   private MemberShareService memberShereService;
	   
	   
	   private final Logger logger = LoggerFactory.getLogger(this.getClass());
	  
	 /**
	  *   /** 商户 */
	    //   index  =0首页
	   //    STORE = 2;
	   //MESSAGE = 1;
	   // AD = 3;
      // AGENT = 6;  
	   //4是论坛
	   //其他5
	
    @ApiOperation(value = "分享接口",  notes = "分享接口")
    @RequestMapping(value = "addShare",method={RequestMethod.POST,RequestMethod.GET})
    @ResponseBody
    public ResultVo addShare(@PathVariable String area,Integer type,Long typeId,Long memberId) {
        try {
        	System.out.println("我的share.........");
        	MemberShare memberShare=new MemberShare();
        	memberShare.setArea(area);
        	memberShare.setCreateDate(new Date());
        	memberShare.setMemberId(memberId);
        	memberShare.setType(type);
        	memberShare.setTypeId(typeId);
        	memberShare.setUpdateDate(new Date());
        	memberShare=memberShereService.save(memberShare);
            if(memberShare.getId()>0) {
             return ResultVoUtil.success("分享成功");
            }else {
                return ResultVoUtil.success("分享失败");

            }
        } catch (Exception e) {
            this.logger.error(e.getMessage(), e);
            return ResultVoUtil.error("接口异常"); 
        } 
    }
	
}


